'''
测试文件不作为模块参考文件
'''
import gdal
import numpy as np
slc_tiff=gdal.Open("/home/gis/gisdata/databackup/gitcode/Orthorectification/data/4-GF3_KAS_FSII_020008_E113.2_N23.1_20200528_L1A_HHHV_L10004829485/4-GF3_KAS_FSII_020008_E113.2_N23.1_20200528_L1A_HHHV_L10004829485/GF3_KAS_FSII_020008_E113.2_N23.1_20200528_L1A_HH_L10004829485.tiff")
slc_prj=slc_tiff.GetProjection()
#slc_sptr=slc_tiff.GetSpatialRef()
slc_trans=slc_tiff.GetGeoTransform()
#栅格矩阵的列数

im_width = slc_tiff.RasterXSize

#栅格矩阵的行数

im_height = slc_tiff.RasterYSize

#波段数

im_bands = slc_tiff.RasterCount

a=slc_tiff.GetRasterBand(1)
b=slc_tiff.GetRasterBand(2)

a=a.ReadAsArray(0,0,im_width,im_height)
b=b.ReadAsArray(0,0,im_width,im_height)

powab=(a**2+b**2)**0.5
slc_tiff_pow=slc_tiff.GetDriver().Create("/home/gis/gisdata/databackup/gitcode/Orthorectification/data/4-GF3_KAS_FSII_020008_E113.2_N23.1_20200528_L1A_HHHV_L10004829485/4-GF3_KAS_FSII_020008_E113.2_N23.1_20200528_L1A_HHHV_L10004829485/Geometric_Correction0/SLC/powe.tiff",
                            im_width,im_height,1,gdal.GDT_Float32)
slc_tiff_pow.SetGeoTransform(slc_trans)
slc_tiff_pow.SetProjection(slc_prj)
band1=slc_tiff_pow.GetRasterBand(1)
band1.WriteArray(powab, 0, 0)

print(a[0][0])
print(slc_prj)
#print(slc_sptr)
print(slc_trans)